package com.hdoit.apollo.logical.inStock.dao.impl;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hdoit.apollo.logical.inStock.dao.IInStockDao;
import com.hdoit.apollo.logical.inStock.mapper.InStockMapper;
import com.hdoit.apollo.logical.inStock.model.InStock;
import com.hdoit.apollo.logical.viewmodel.stock.InStockSearch;
import com.tennetcn.data.dao.base.ISqlExpression;
import com.tennetcn.data.dao.base.impl.SuperDao;
import com.tennetcn.data.message.PagerModel;
import com.tennetcn.data.utils.SqlExpressionFactory;
/**
 * @author      tancongzhu
 * @email       
 * @createtime  2018年04月02日 11:46:28
 * @comment
 */
@Component
public class InStockDaoImpl extends SuperDao<InStock> implements IInStockDao{
	@Autowired
	private InStockMapper inStockMapper;
	
	@Override
	public InStock queryModelById(String key) {
		return inStockMapper.queryModelById(key);
	}

	@Override
	public List<InStock> queryInStockHistoryListByKey(String key) {
		
		return inStockMapper.queryInStockHistoryListByKey(key);
	}

	@Override
	public InStock queryModelByKey(String key) {
		
		return inStockMapper.queryModelByKey(key);
	}

	@Override
	public int queryCountMPForReturn(InStockSearch search) {
		
		return inStockMapper.queryCountMPForReturn(search);
	}

	@Override
	public List<InStock> queryListMPForReturn(InStockSearch search,PagerModel pagerModel) {

		return inStockMapper.queryListMPForReturn(search,pagerModel);
	}

	@Override
	public InStock queryModelBySee(String key) {
		
		return inStockMapper.queryModelBySee(key);
	}

	@Override
	public boolean deleteInStockByKey(String inStockId) {
		ISqlExpression sqlExpression = SqlExpressionFactory.createExpression();
		sqlExpression.addBody("delete from",InStock.class)
					.andWhere("inStockId=#{inStockId}")
					.setParam("inStockId", inStockId);
		return delete(sqlExpression)>=0;
	}

}